import request from '@/utils/request';
export async function queryRule(params) {
  const limit = params.pageSize;
  const page = params.current;
  const my_params = {
    limit: limit || 30,
    page: page || 1,
  };
  Object.assign(params, my_params);
  delete params.current;
  delete params.pageSize;
  return request('store/store/page', {
    params,
  });
}
export async function allStore(params) {
  return request('store/store/allList', {
    params,
  });
}
export async function removeRule(params) {
  return request(`store/store/${params}`, {
    method: 'DElETE',
  });
}
export async function addRule(params) {
  return request('/store/store', {
    method: 'POST',
    data: {
      ...params,
    },
  });
}
export async function updateRule(params) {
  return request('/store/store', {
    method: 'PUT',
    data: {
      ...params,
    },
  });
}
export async function getDictionary(params, id) {
  return request(
    id ?
    `common/dictionary/list/?module=${params}&parentId=${id}` :
    `common/dictionary/list/?module=${params}`,
  );
}

export async function queryDepartment(params) {
  return request('/dept/list', {
    params,
  });
}

export async function getCaptcha(params) {
  return request('/captcha', {
    params,
    responseType: 'blob',
  });
}
export async function storeCommodity(params) {
  return request(`/store/goodsStore/list?storeId=${params.id}`, {
    params,
  });
}

export async function commodityUpdate(params) {
  return request(`/store/goodsStore/batch?goodsItemId=${params.id}`, {
    method: 'PUT',
    data: params.data,
  });
}
export async function commodityUpdatePrice(params) {
  return request(`/store/goodsStore/updatePrice?goodsItemId=${params.id}`, {
    method: 'PUT',
    data: params.data,
  });
}
export async function exportStoreStock(params) {
  return request(`/store/goodsStore/export`, {
    method: 'GET',
    params,
    responseType: 'blob',
  });
}

export async function exportStore(params) {
  return request(`/store/store/export`, {
    method: 'GET',
    data: params,
    responseType: 'blob',
  });
}
export async function lklAddTerm(data) {
  return request('/store/store/addLklTerm', {
    method: 'POST',
    data
  });
}
